package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.SellOutBean;
import com.mz.ozy.mvp.model.SellOutModel;
import com.mz.ozy.mvp.view.SellOutContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class SellOutPresenter extends BasePresenterImpl<SellOutContract.View> implements SellOutContract.Presenter{

    private SellOutModel mModel;

    public SellOutPresenter(){
        mModel = new SellOutModel();
    }


    @Override
    public void geAssetsInfo(Activity activity, String type) {
        mModel.geAssetsInfo(activity,type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<SellOutBean>(mView){
                    @Override
                    public void onSuccesss(SellOutBean bean) {
                        mView.geAssetsInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void submit(Context context, String type, String sellNum, String pass, String floatRate) {
        mModel.submit(context,type,sellNum,pass,floatRate)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<SellOutBean>(mView){
                    @Override
                    public void onSuccesss(SellOutBean bean) {
                        mView.submitSuccess(bean);
                    }
                });
    }
}
